package com.ptszyxx.popose.module.main.home.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.common.utils.YActivityUtil;
import com.ptszyxx.popose.databinding.ItemHomeSearchBinding;
import com.ptszyxx.popose.module.main.home.vm.HomeSearchVM;
import com.ysg.http.data.entity.home.HomeSearchEntity;

public class HomeSearchAdapter extends BaseQuickAdapter<HomeSearchEntity, BaseDataBindingHolder<ItemHomeSearchBinding>> {
    private HomeSearchVM viewModel;
    private Presenter mPresenter = new Presenter();

    public HomeSearchAdapter(HomeSearchVM viewModel) {
        super(R.layout.item_home_search);
        this.viewModel = viewModel;
    }

    @Override
    protected void convert(BaseDataBindingHolder<ItemHomeSearchBinding> holder, HomeSearchEntity item) {
        ItemHomeSearchBinding binding = holder.getDataBinding();
        if (binding != null) {
            binding.setEntity(item);
            binding.setViewModel(viewModel);
            binding.setPresenter(mPresenter);
            binding.executePendingBindings();
        }
    }

    public static class Presenter{
        public void onItemClick(HomeSearchVM viewModel, HomeSearchEntity entity){
            YActivityUtil.getInstance().jumpUserDetail(viewModel, entity.getId());
        }
    }







}
